package main

import (
	"admin-server/controller"
	"admin-server/libs"
	"admin-server/middleware"
	"github.com/gin-gonic/gin"
)

var (
	app *gin.Engine
)

// 公开路由
func publicRouter() {
	app.POST("/account/login", controller.AccountLogin)
}

// 私有路由,即需要登录授权的路由
func privateRouter() {
	app.GET("/account/current", controller.CurrentAccountInfo)

	app.GET("/article/get_list", controller.GetArticleList)
}

// 初始化
func initApp() {
	app = gin.Default()
	publicRouter()

	app.Use(middleware.AuthMiddleware())
	privateRouter()
}

// 程序入口
func main() {
	config := libs.GetConfig()
	initApp()

	err := app.Run(":" + config.Port)
	if err != nil {
		panic(err)
	}
}
